import java.text.ParseException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


/*
 * @(#)Author.java
 *
 */

/**
 * description
 * @author  huangyixiang
 * @version 2012-7-13
 */
public class Author {
	
	
	public static void main(String[] args) throws ParseException {
		long t1 = System.currentTimeMillis();
//		 String AuthorReg ="(?:\\(.+\\))?(.+?)(,(.+?))*(?:\\(.+\\))?";
		 String AuthorReg ="(?:[（〔\\(].+?[）〕\\)])?(.+?)(?:[（〔\\(].+?[）〕\\)])?";
		 Pattern p = Pattern.compile("(?:(.*?)\\s+等?\\s*著?\\s*著作)?\\s*(?:(.*?)\\s主编)?\\s*(?:(.*?)\\s编者)?\\s*(?:(.*?)\\s译者)?");
		 Matcher m = p.matcher("(美)尼尔德-格里希 著 著作 万鹏//董潇潇　译者");
		 Pattern p1 = Pattern.compile(AuthorReg);
		 Matcher m1 = p1.matcher("万鹏//董潇潇");
		 
		 String a = "[意大利]()但丁";
		 System.out.println(a.replaceAll(a, "-------------------------"));
		 
		 
		 System.out.println("----------------------------------------");
//		 System.out.println(m.group(3) + "      " + m.group(7)+"     " + m.group(11)+"      " + m.group(15));
		 m.matches();
		 for(int i = 0 ; i <= m.groupCount() ; i++){
			 System.out.println("" + i + " = " + m.group(i)); 
//			 for(String str : m.group(i).split(",|，")){
//				 System.out.println(str);
//			 }
		 }
		 System.out.println("----------------------------------------");
		 m1.matches();
		 for(int i = 0 ; i <= m1.groupCount() ; i++){
			 System.out.println("" + i + " = " + m1.group(i));
//			 for(String str : m.group(i).split(",|，")){
//				 System.out.println(str);
//			 }
		 }
		 
//		 Pattern p1 = Pattern.compile(AuthorReg);
//		 Matcher m1 = p1.matcher("(英国)乔伊(joe)");
//		 System.out.println(m1.matches());
//		 for(int i = 0 ; i < 10 ; i++){
//			 System.out.println("" + i + " = " + m1.group(i));
//		 }
		 System.out.println(System.currentTimeMillis()-t1 +" ms");
	}

}
